@@ -58,7 +58,12 @@ module WebRequestConcern |
||
| 58 | 58 |
end |
| 59 | 59 |
|
| 60 | 60 |
def user_agent |
| 61 |
- interpolated['user_agent'].presence || |
|
| 61 |
+ interpolated['user_agent'].presence || self.class.default_user_agent |
|
| 62 |
+ end |
|
| 63 |
+ |
|
| 64 |
+ module ClassMethods |
|
| 65 |
+ def default_user_agent |
|
| 62 | 66 |
ENV.fetch('DEFAULT_HTTP_USER_AGENT', Faraday.new.headers[:user_agent])
|
| 67 |
+ end |
|
| 63 | 68 |
end |
| 64 | 69 |
end |
@@ -50,7 +50,7 @@ module Agents |
||
| 50 | 50 |
|
| 51 | 51 |
Set `force_encoding` to an encoding name if the website does not return a Content-Type header with a proper charset. |
| 52 | 52 |
|
| 53 |
- Set `user_agent` to a custom User-Agent name if the website does not like the default value ("Faraday v#{Faraday::VERSION}").
|
|
| 53 |
+ Set `user_agent` to a custom User-Agent name if the website does not like the default value (`#{default_user_agent}`).
|
|
| 54 | 54 |
|
| 55 | 55 |
The `headers` field is optional. When present, it should be a hash of headers to send with the request. |
| 56 | 56 |
|